home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 1357 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.6 KB

  1. Path: news.chalmers.se!usenet
  2. From: ditt login@ios.chalmers.se (Ange ditt namn)
  3. Newsgroups: comp.lang.c++
  4. Subject: Stupid DialogBox() fails....
  5. Date: 10 Jan 1996 17:12:15 GMT
  6. Organization: Chalmers university of technology
  7. Message-ID: <4d0s1f$je2@nyheter.chalmers.se>
  8. Reply-To: ei39594@ios.chalmers.se
  9. NNTP-Posting-Host: sv320112.ios.chalmers.se
  10. X-Newsreader: WinVN 0.92.1
  11.  
  12.  
  13. Hi' 
  14.  
  15. I'm writing a Windowz based app. using BC4, and everything seems to work 
  16. fine until I close BC and try to run my program without the IDE:
  17. and then EVERY STUPID DIALOGBOX() FAILS...
  18. I don't know why, but one thing is for sure: the code sshould be OK, I ripped it out 
  19. from Borlands Example files :-) 
  20. My program worked just fine if I had any of BC programs (e.g. Winsight) running,
  21. should i try compile it dynamic??
  22.  
  23. I'm using Win95, but I had the same problem with wfwg3.11 and BC4.5
  24.  
  25. The code looks like this:
  26. -------------------------
  27. DLGPROC AboutProc;
  28. HINSTANCE Hinst; /* make it global in main */
  29. BOOL CALLBACK _export AboutDlgProc(HWND hWnd,UINT msg,
  30.     WPARAM wParam,LPARAM lParam){
  31.     switch(msg){
  32.         case WM_COMMAND:
  33.             switch(wParam){
  34.                 case ABOUT_OK:        
  35.                     EndDialog(hWnd,TRUE);        
  36.                     break;
  37.                 }    
  38.                 break;
  39.             default:    return FALSE;
  40.         }        
  41.     return TRUE;    
  42.     }
  43.  
  44. void About(HWND hWnd){
  45.     AboutProc = (DLGPROC) MakeProcInstance((FARPROC)AboutDlgProc,Hinst);
  46.     if(AboutProc){
  47.         if(DialogBox(Hinst,"About",hWnd,AboutProc) == -1)
  48.             MessageBox(hWnd,"INTERNAL: DialogBox() failed!",0L,MB_OK);
  49.         FreeProcInstance((FARPROC) AboutProc);
  50.         } else MessageBox(hWnd,"INTERNAL: MakePoocInstance() failed!",0L,MB_OK);
  51.     }
  52.  
  53. ------------------------
  54.  
  55. As you see this is my first Windowz prog. :-)
  56.  
  57. TIA, Arash
  58.  
  59.